﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ionic.Zip;
using System.IO;


namespace ZipperForBinaryFiles
{
    class ZipperForBinaryFiles
    {
        public static void ZipFiles(string zipName, params string[] fileNames)
        {
            ZipFile zip = new ZipFile();
            using (zip)
            {
                foreach (string fileName in fileNames)
	            {
		            zip.AddFile(fileName, ".");
	            }
                zip.Save(zipName);
            }
        }

        public static void UnzipFiles(string zipName)
        {
            FileInfo zipFile = new FileInfo(zipName);
            string unzipDirectory = zipFile.FullName;
            unzipDirectory = unzipDirectory.Replace(".zip", "");
            
            ZipFile zip = new ZipFile(zipName);
            using (zip)
            {
                foreach (ZipEntry file in zip)
                {
                    file.Extract(unzipDirectory, ExtractExistingFileAction.OverwriteSilently);
                }
            }
        }

        static void Main(string[] args)
        {
            char Separator = Path.DirectorySeparatorChar;
            string zipName = String.Format("..{0}..{0}myZip.zip", Separator);
            string[] files = {String.Format("..{0}..{0}file1.txt", Separator),
                                 String.Format("..{0}..{0}file2.txt", Separator),
                                 String.Format("..{0}..{0}file3.txt", Separator)};
            ZipFiles(zipName, files);
            //UnzipFiles(zipName);
        }
    }
}
